﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Control_Layer;

namespace Mindmap_Case_4
{
    public partial class Presentation : Form
    {
        public Presentation()
        {
            InitializeComponent();
            initiate();
        }

        private Bitmap screen;

        private CCRunPresentation ccRunPresentation;

        private void initiate()
        {
            screen = new Bitmap(800, 600);
        }

        /// <summary>
        /// Loads the presentation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Presentation_Load(object sender, EventArgs e)
        {
            ccRunPresentation = new CCRunPresentation();
            ccRunPresentation.AddPresentation();
            drawDia(ccRunPresentation.Show(screen));
        }

        /// <summary>
        /// Keeps track of the user scrolling through the dias.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Presentation_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                drawDia(ccRunPresentation.NextDia(screen));
            }
            else if (e.Button == MouseButtons.Right)
            {
                drawDia(ccRunPresentation.PreviousDia(screen));
            }
        }

        /// <summary>
        /// Draws dia on this Forms screen.
        /// </summary>
        /// <param name="dia">Dia to be drawn on screen.</param>
        private void drawDia(Bitmap dia)
        {
            using (Graphics g = this.CreateGraphics())
            {
                g.DrawImage(dia, this.Width / 6, 0, this.Width - ((this.Width / 6) * 2), this.Height);
            }
        }

        /// <summary>
        /// Keeps track of user wanting to end the presentation by pressing the Escape Key.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Presentation_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.Close();
                this.Dispose();
            }
        }
    }
}
